/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Aug 28, 2013  1:58:10 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.database.dao.security.impl
 * File Name : AdUserGroupDaoImpl.java
 * TODO
 */
package com.tis.database.dao.security.impl;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import promis.utility.CommonService;

import com.tis.database.dao.impl.AbstractDaoImpl;
import com.tis.database.dao.security.AdUserGroupDao;
import com.tis.database.entitys.security.AdActiveDirectory;
import com.tis.database.entitys.security.AdUserGroup;

/**
 * @author Administrator
 *
 */
@Repository
@SuppressWarnings("unchecked")
public class AdUserGroupDaoImpl extends AbstractDaoImpl<AdUserGroup, BigDecimal> implements AdUserGroupDao {
	
	private static final Logger log = LoggerFactory.getLogger(AdUserGroupDaoImpl.class);
	
	/**
	 * @param entityClass
	 */
	public AdUserGroupDaoImpl() {
		super(AdUserGroup.class);
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByAdActiveDirectory(com.tis.database.entitys.security.AdActiveDirectory)
	 */
	@Override	
	public List<AdUserGroup> findByAdActiveDirectory(AdActiveDirectory adActiveDirectory) throws HibernateException{
		String hqlString = " from AdUserGroup where adActiveDirectoryId = :adActiveDirectoryId ";
		HashMap<String, String> parameter = new HashMap<String, String>();
		parameter.put("adActiveDirectoryId", CommonService.IsNullRString(adActiveDirectory.getPkId()));
		
		return findHQLByQuery(hqlString, parameter);
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByCode(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByCode(String code) {
		
		return findByCriteria(Restrictions.like("code", code, MatchMode.ANYWHERE));
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByName(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByName(String name) {
		
		return findByCriteria(Restrictions.like("name", name, MatchMode.ANYWHERE));
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByDescription(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByDescription(String description) {
		
		return findByCriteria(Restrictions.like("description", description, MatchMode.ANYWHERE));
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByIsActive(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByIsActive(String isactive) {
		
		return findByCriteria(Restrictions.like("isactive", isactive, MatchMode.ANYWHERE));
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByIsDelete(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByIsDelete(String isdeleted) {
		
		return findByCriteria(Restrictions.like("isdeleted", isdeleted, MatchMode.ANYWHERE));
	}

	/* (non-Javadoc)
	 * @see com.tis.database.dao.security.AdUserGroupDao#findByStatus(java.lang.String)
	 */
	@Override	
	public List<AdUserGroup> findByStatus(String status) {
		
		return findByCriteria(Restrictions.like("status", status, MatchMode.ANYWHERE));
	}

}
